package com.oreilly.ez.base;

public enum ConstEnum {


    R_400("400", "Bad Request!"),
    R_401("401", "NotAuthorization"),
    R_405("405", "Method Not Allowed"),
    R_406("406", "Not Acceptable"),
    R_500("500", "Internal Server Error"),
    R_1000("1000", "[服务器]运行时异常"),
    R_1001("1001", "[服务器]空值异常"),
    R_1002("1002", "[服务器]数据类型转换异常"),
    R_1003("1003", "[服务器]IO异常"),
    R_1004("1004", "[服务器]未知方法异常"),
    R_1005("1005", "[服务器]数组越界异常"),
    R_1006("1006", "[服务器]网络异常"),
    R_1010("1010", "用户未注册"),
    R_1011("1011", "用户已注册"),
    R_1012("1012", "用户名或密码错误"),
    R_1013("1013", "用户帐号冻结"),
    R_1014("1014", "用户信息编辑失败"),
    R_1015("1015", "用户信息失效，请重新获取"),
    R_1020("1020", "验证码发送失败"),
    R_1021("1021", "验证码失效"),
    R_1022("1022", "验证码错误"),
    R_1023("1023", "验证码不可用"),
    R_1029("1029", "短信平台异常"),
    R_1030("1030", "周边无店铺"),
    R_1031("1031", "店铺添加失败"),
    R_1032("1032", "编辑店铺信息失败"),
    R_1033("1033", "每个用户只能添加一个商铺"),
    R_1034("1034", "店铺不存在"),
    R_1040("1040", "无浏览商品"),
    R_1041("1041", "添加失败"),
    R_1042("1042", "商品不存在"),
    R_1043("1043", "商品删除失败"),
    R_2010("2010", "缺少参数或值为空"),
    R_2029("2029", "参数不合法"),
    R_2020("2020", "无效的Token"),
    R_2021("2021", "无操作权限"),
    R_2022("2022", "RSA解密失败"),
    R_2023("2023", "请重新登录");


    private String code;
    private String text;


    ConstEnum(String code, String text) {
        this.code = code;
        this.text = text;
    }


    public String getText() {
        return text;
    }

    public String getCode() {
        return code;
    }


    public static ConstEnum get(String code) {

        ConstEnum[] values = ConstEnum.values();
        for (ConstEnum value : values) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }

        return null;

    }
}
